// 引入等比适配插件
const px2rem = require("postcss-px2rem");

// 配置基本大小
const postcss = px2rem({
  // 基准大小 baseSize，需要和rem.js中相同
  remUnit: 16
});
// 使用等比适配插件
// const webpack = require("webpack");
const ThemeColorReplacer = require("webpack-theme-color-replacer");
const forElementUI = require("webpack-theme-color-replacer/forElementUI");

const appConfig = require("./config/app-config.js");
module.exports = {
  devServer: {
    proxy: {
      "/": {
        changeOrigin: true,
        target: "https://autumnfish.cn/"
      }
    }
  },
  configureWebpack: {
    plugins: [
      // 生成仅包含颜色的替换样式（主题色等）
      new ThemeColorReplacer({
        fileName: "style/theme-colors.[contenthash:8].css",
        matchColors: [...forElementUI.getElementUISeries(appConfig.themeColor)],
        changeSelector: forElementUI.changeSelector,
        isJsUgly: process.env.NODE_ENV === "production" ? true : undefined
      })
    ]
  },
  lintOnSave: false,
  css: {
    loaderOptions: {
      postcss: {
        plugins: [postcss]
      }
    }
  }
};
